<h1>DefineFont2</h1>

<p>efineFont2 defines the shapes and layout of the glyphs used in a font. It extends 
the functionality provided by DefineFont by:</p>

<div style="padding-left:20px; margin-bottom:10px;">
<ul>
<li>allowing more than 65535 glyphs in a particular font.</li>
<li>including the functionality provided by the FontInfo class.</li>
<li>specifying ascent, descent and leading layout information for the font.</li>
<li>specifying advances for each glyph.</li>
<li>specifying bounding rectangles for each glyph.</li>
<li>specifying kerning pairs defining the distance between pairs of glyphs.</li>
</ul>
</div>

<p>The DefineFont2 class combines the attributes of FontInfo and DefineFont 
in a single definition:</p>

<table>

<tr>
<th nowrap>Field Name</th>
<th>Type</th>
<th>Size</th>
<th>Description</th>
</tr>

<tr>
<td nowrap valign="top">type</td>
<td nowrap valign="top"></td>
<td nowrap valign="top" align="right">&nbsp;</td>
<td>Identifies the DefineFont3 data structure when it is encoded. It is encoded 
with the length field as a 16-bit integer (Little-endian byte order).</td>
</tr>

<tr>
<td nowrap valign="top">length</td>
<td nowrap valign="top">unsigned bit</td>
<td nowrap valign="top" align="right">6</td>
<td>The length in bytes of the body of the instruction when it is encoded. If the length is greater 
than 62 then this field is set to 0x3F and the length is encoded using the 
extendedLength field. Encoded with the type field as a 16-bit integer.</td>
</tr>

<tr>
<td nowrap valign="top">extendedLength</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">32</td>
<td>Optional. Contains the length in bytes of the encoded instruction if it is
greater than 62 bytes. If the length is 62 bytes or less then this field is 
omitted.</td>
</tr>

<tr>
<td nowrap valign="top">identifier</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">16</td>
<td>The unique identifier for this font definition. This is used when adding or removing 
the shape from the display list or when the shape is used as part of another 
object such as a button.</td>
</tr>

<tr>
<td nowrap valign="top">hasLayout</td>
<td nowrap valign="top">boolean</td>
<td nowrap valign="top" align="right">1</td>
<td>Whether the font contain information for laying out glyphs.</td>
</tr>

<tr>
<td nowrap valign="top">isShiftJIS</td>
<td nowrap valign="top">boolean</td>
<td nowrap valign="top" align="right">1</td>
<td>Are the character codes encoded using the ShiftJIS character set.</td>
</tr>

<tr>
<td nowrap valign="top">isSmall</td>
<td nowrap valign="top">boolean</td>
<td nowrap valign="top" align="right">1</td>
<td>Are the glyphs drawn to align with pixel boundaries.</td>
</tr>

<tr>
<td nowrap valign="top">isANSI</td>
<td nowrap valign="top">boolean</td>
<td nowrap valign="top" align="right">1</td>
<td>Are the character codes encoded using the ANSI (ASCII) character set.</td>
</tr>

<tr>
<td nowrap valign="top">isWideOffsets</td>
<td nowrap valign="top">boolean</td>
<td nowrap valign="top" align="right">1</td>
<td>Does the index table for glyphs contain 16-bit (false) or 32-bit (true) entries.</td>
</tr>

<tr>
<td nowrap valign="top">isWideCodes</td>
<td nowrap valign="top">boolean</td>
<td nowrap valign="top" align="right">1</td>
<td>Are the character codes encoded as 16-bit values (true) or 8-bit (false).</td>
</tr>

<tr>
<td nowrap valign="top">isItalic</td>
<td nowrap valign="top">boolean</td>
<td nowrap valign="top" align="right">1</td>
<td>Whether the font is italicised.</td>
</tr>

<tr>
<td nowrap valign="top">isBold</td>
<td nowrap valign="top">boolean</td>
<td nowrap valign="top" align="right">1</td>
<td>Whether the font is bold.</td>
</tr>

<tr>
<td nowrap valign="top">language</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">8</td>
<td>Identifies the spoken language for the font, either Japanese, Korean, 
 Latin, Simplified Chinese or Traditional Chinese. This attribute 
is used when displaying text fields and assists in determining language-appropriate
line breaks.</td>
</tr>

<tr>
<td nowrap valign="top">nameLength</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">8</td>
<td>The number of characters in the string containing the name of the font.</td>
</tr>

<tr>
<td nowrap valign="top">name</td>
<td nowrap valign="top">String</td>
<td nowrap valign="top" align="right">&lt;nameLength&gt;</td>
<td>The name of the font.</td>
</tr>

<tr>
<td nowrap valign="top">glyphCount</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">16</td>
<td>The number of glyphs defined in the font.</td>
</tr>

<tr>
<td nowrap valign="top">glyphTable</td>
<td nowrap valign="top">unsigned int[glyphCount]</td>
<td nowrap valign="top" align="right">16 or 32</td>
<td>An array of offsets to each glyph. Each entry is either 16 0r 32 bits 
depending on whether the hasWideOffsets flag is false or true respectively.</td>
</tr>

<tr>
<td nowrap valign="top">offsetToCodes</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">16 or 32</td>
<td>The offset in bytes to the start of the table containing the character codes.
This field is either 16 0r 32 bits depending on whether the hasWideOffsets 
flag is false or true respectively.</td>
</tr>

<tr>
<td nowrap valign="top">glyphs</td>
<td nowrap valign="top">Shape[glyphCount]</td>
<td nowrap valign="top" align="right">&nbsp;</td>
<td>An array of Shapes that define the outline for each glyph.</td>
</tr>

<tr>
<td nowrap valign="top">codes</td>
<td nowrap valign="top">unsigned int[glyphCount]</td>
<td nowrap valign="top" align="right">8 or 16</td>
<td>An array mapping a glyph index to a particular character code in the font.
The size of the entry is either 8 or 16 bits depending on whether the
hasWideCodes flag is false or true.</td>
</tr>

</table>

<p>Additional layout information for the glyphs in the font can also be specified through the following set of attributes:</p>

<table>

<tr>
<td nowrap valign="top">ascent</td>
<td nowrap valign="top">signed int</td>
<td nowrap valign="top" align="right">16</td>
<td>The maximum ascent for the font in twips.</td>
</tr>

<tr>
<td nowrap valign="top">descent</td>
<td nowrap valign="top">signed int</td>
<td nowrap valign="top" align="right">16</td>
<td>The maximum descent for the font in twips.</td>
</tr>

<tr>
<td nowrap valign="top">leading</td>
<td nowrap valign="top">signed int</td>
<td nowrap valign="top" align="right">16</td>
<td>The leading for the font.</td>
</tr>

<tr>
<td nowrap valign="top">advances</td>
<td nowrap valign="top">signed int[glyphCount]</td>
<td nowrap valign="top" align="right">16</td>
<td>An array of 16-bit integers that define the advance for each glyph in the font.</td>
</tr>

<tr>
<td nowrap valign="top">bounds</td>
<td nowrap valign="top">Bounds[glyphCount]</td>
<td nowrap valign="top" align="right">&nbsp;</td>
<td>An array that define the bounding rectangle for each glyph in the font.</td>
</tr>

<tr>
<td nowrap valign="top">kerningCount</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">16</td>
<td>The number of Kernings define for pairs of glyphs..</td>
</tr>

<tr>
<td nowrap valign="top">kernings</td>
<td nowrap valign="top"></td>
<td nowrap valign="top" align="right">&nbsp;</td>
<td>An array of Kerning structures that define adjustment to the advance for 
particular pairs of glyphs in the font.</td>
</tr>
</table>

<h2>History</h2>

<p>DefineFont2 class represents the DefineFont2 structure from the Macromedia 
Flash (SWF) File Format Specification. It was introduced in Flash 2. Support for
spoken languages was added in Flash 6. Support for small point size fonts was 
added in Flash 7.</p>
